package com.ichina.chat.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.ichina.chat.dao.TypeDao;
import com.ichina.chat.vo.Type;
@Component @Transactional
public class TypeDaoimpl implements TypeDao {

	@Resource
	SessionFactory sessionFactory;;
	private Session session = null;
	private Query query = null;
	private String hql = "";
	private int count = 0;

	public boolean addType(Type type) throws Exception {
		try{
			sessionFactory.getCurrentSession().persist(type);
		}catch(Exception e){
			e.printStackTrace();
			return false;
		}
		return true;
	}

	public boolean delType(int typeid) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}

	@SuppressWarnings("unchecked")
	public List<Type> getAll() throws Exception {
		return sessionFactory.getCurrentSession().createCriteria(Type.class).list();
	}

	public Type loadById(int typeid) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	public boolean updateType(Type type) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}

}
